using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;

using Pampa.WebControls.UI.Exceptions;

namespace Pampa.WebControls
{
    public class OpenWindowButton : ClientButton
    {
        protected string floatingWindowID;
        protected string preOpeningMethod;
        protected bool modal;

        #region Constructores

        public OpenWindowButton() : base()
        {
            modal = false;
        }

        #endregion

        #region Properties

        public string FloatingWindowID
        {
            get { return floatingWindowID; }
            set { floatingWindowID = value; }
        }

        public string PreOpeningMethod
        {
            get { return preOpeningMethod; }
            set { preOpeningMethod = value; }
        }

        public bool Modal
        {
            get { return modal; }
            set { modal = value; }
        }

        #endregion

        #region Render

        protected override void Render(HtmlTextWriter writer)
        {
            base.Render(writer);
        }

        #endregion

        #region Protected Functions

        protected override string GetMethod()
        {
            string functionDef = this.preOpeningMethod;

            if (!string.IsNullOrEmpty(functionDef))
            {
                if (functionDef.IndexOf("(") == -1)
                    functionDef += "()";
                if (functionDef.IndexOf(";") == -1)
                    functionDef += ";";
            }

            return functionDef + "OpenFloatingWindow('" + floatingWindowID + "', " + this.Modal.ToString().ToLower() + ");";
        }

        #endregion
    }
}
